package com.cf.api.db;

import com.cf.api.dao.MSSQLMapper;
import com.md.common.utils.dao.MyMapper;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tk.mybatis.spring.mapper.MapperScannerConfigurer;

/**
 * 功能描述：Mybatis MapperScanner配置
 *
 * @author lujianping@kuparts.com
 * @version 1.0
 * @date 2017/9/14 17:30
 * @since JDK 1.8
 */
@Configuration
@AutoConfigureAfter(MyBatisConfig.class)
public class MyBatisScannerConfig {

    @Bean
    @Qualifier("mapperScannerConfigurer")
    public MapperScannerConfigurer mapperScannerConfigurer() {
        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
        mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
        mapperScannerConfigurer.setBasePackage("com.md.**.dao");
        mapperScannerConfigurer.setMarkerInterface(MyMapper.class);
        return mapperScannerConfigurer;
    }

    @Bean
    @Qualifier("otherMapperScannerConfigurer")
    public MapperScannerConfigurer otherMapperScannerConfigurer() {
        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
        mapperScannerConfigurer.setSqlSessionFactoryBeanName("otherSqlSessionFactory");
        mapperScannerConfigurer.setBasePackage("com.cf.**.dao");
        mapperScannerConfigurer.setMarkerInterface(MSSQLMapper.class);
        return mapperScannerConfigurer;
    }
}
